<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/template.xhtml">

	<ui:define name="content">

		<f:view>
			<h:form>
				<br />
				<div class="middle">
					<h2> Users </h2>
				</div>
				<br />
				<div class="middle">
					<h:outputText value="#{ub.message}"></h:outputText>
				</div>
				<div class="middle">
					<h:commandButton class="button" align="center"
						actionListener="#{ub.goToCreate}" value="#{msg.AD_users_createUser}"></h:commandButton>
				</div>
				<br />
				<div class="middle">
					<h:outputText value="#{msg.AD_users_searchByUser}"></h:outputText>
					<h:inputText id="search" value="#{ub.search}">
						<f:ajax event="keyup" listener="#{ub.searchUsers}" render="user"></f:ajax>
					</h:inputText>
				</div>
				<br />
				<h:dataTable width="100%" id="user" class="table" border="1" value="#{ub.users}"
					var="user">
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_domain}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								action="#{ub.ascDomain}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								action="#{ub.descDomain}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{ub.getDomain(user.idDomain).name}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_name}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								actionListener="#{ub.ascName}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								actionListener="#{ub.descName}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{user.name}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_email}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								action="#{ub.ascEmail}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								action="#{ub.descEmail}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{user.email}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_username}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								action="#{ub.ascUsername}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								action="#{ub.descUsername}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{user.username}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_isActive}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								action="#{ub.ascIsactive}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								action="#{ub.descIsactive}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{msg.AD_users_isActive}" rendered="#{user.isActive == 1}"></h:outputText>
						<h:outputText value="#{msg.AD_users_isInactive}" rendered="#{user.isActive != 1}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_usertype}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								action="#{ub.ascUsertype}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								action="#{ub.descUsertype}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{ub.getUserType(user.idUsertype).name}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_replacedby}"/>
							<br />
							<h:commandButton class="upBtn" value="Asc"
								action="#{ub.ascReplaced}"></h:commandButton>
							<h:commandButton class="downBtn" value="Desc"
								action="#{ub.descReplaced}"></h:commandButton>
						</f:facet>
						<h:outputText value="#{ub.getUser(user.idUser).name}"></h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header"><h:outputText value="#{msg.AD_users_action}"/>
							<br />
						</f:facet>
						<h:commandButton class="editBtn" value="#{msg.OM_resourcecrud_edit}"
							actionListener="#{ub.getUserEdit}">
							<f:attribute name="userid" value="#{user.id}" />
						</h:commandButton>
						<h:commandButton class="trashBtn" value="Delete"
							actionListener="#{ub.deleteUserListener}"
							onclick="#{msg.AD_editUser_confMessage}">
							<f:attribute name="userid" value="#{user.id}" />
						</h:commandButton>
					</h:column>
				</h:dataTable>
			</h:form>
		</f:view>
	</ui:define>
</ui:composition>
</html>